package com.lvt.example.thinking.in.spring.questions.L19.bean.definine.example03.fix;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * desc：HelloController
 *
 * @author LT
 * @date 2022/10/2
 */
@RestController
public class HelloController {

    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping(path = "hi", method = RequestMethod.GET)
    public String hi() {
        return "helloworld, service is : " + getServiceImpl();
    }

    public ServiceImpl getServiceImpl() {
        return applicationContext.getBean(ServiceImpl.class);
    }

    // 修复方式二
//    @Lookup
//    public ServiceImpl getServiceImpl() {
//        return null;
//    }

}
